<%@ page contentType="text/html;charset=UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ taglib uri="/tld/dictionary" prefix="dictionary"%>
<%@ taglib uri="/tld/flowdictionary" prefix="flowdictionary"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=7" />
<link rel="stylesheet" href="${ctx}/static/css/style.css" type="text/css" /> 
<link rel="stylesheet" href="${ctx}/static/css/style1.css" type="text/css" /> 
<link rel="stylesheet" href="${ctx}/static/css/kongjian.css" type="text/css" /> 
<link rel="stylesheet" href="${ctx}/static/css/jquery.ui.all.css" type="text/css"/>
<link rel="stylesheet" href="${ctx}/static/css/thickbox.css" type="text/css"/>
<script src="${ctx}/static/script/jquery-1.4.min.js" type="text/javascript"></script>
<script src="${ctx}/static/script/jquery.ui.core.js" type="text/javascript"></script>
<script src="${ctx}/static/My97DatePicker/WdatePicker.js" type="text/javascript"></script>
<script src="${ctx}/static/script/js_validator.js" type="text/javascript"></script>
<script src="${ctx}/static/script/thickbox.js" type="text/javascript"></script>
<script src="${ctx}/static/script/jsCoreUtil.js" type="text/javascript"></script>
<title>投资管理</title>
<script language="JavaScript">
function jumpPage(pageNo) {
	document.getElementById('pageNo').value=pageNo;
	document.getElementById('mainForm').submit();
}
function confirmInvalid(invest_id){
	if(confirm("确认作废?")){
		window.location.href="${ctx}/fortune/invest_to_void/"+invest_id;
	}
}
function OpenMatchWindow()
{	
 	var thisform = document.getElementById('mainForm');
 	thisform.action = '${ctx}/recommend/recommend_add_init';
 	thisform.submit();
}
function listsubmit_(){
	var thisform = document.getElementById('mainForm');
	var investstartdate = thisform.investStartDate.value;
	var investendtdate = thisform.investEndDate.value;
	var isTrue=true;
	/*
	if(investstartdate=='' && investendtdate!=''){
		alert('未输入开始日期!');isTrue=false;
	}else{
		isTrue=true;
	}
	if(investstartdate!='' && investendtdate==''){
		alert('未输入结束日期!');isTrue=false;
	}else{
		isTrue=true;
	}
	if(investstartdate!= '' && investendtdate!='' ){
		if(! compareDate(investstartdate,investendtdate)){
			alert('结束日期不能小于开始日期!');isTrue=false;
		}else{
			isTrue=true;
		}
	}
	*/
	if(isTrue==true){
		thisform.submit();
	}
}
function recommend(deliveryDate,investId){
	var thisform = document.getElementById('mainForm');
 	thisform.deliveryDate.value=deliveryDate;
 	thisform.investId.value=investId;
 	thisform.return_Date.value = deliveryDate;
	tb_show('','#TB_inline?height=150&amp;width=250&amp;inlineId=showbox&amp;modal=true','');
}
</script>
</head>
<body>
<form:form id="mainForm" action="${ctx}/fortune/invest_list" modelAttribute="fortuneListForm" method="post">
<div class="er_banner">投资管理 </div>
<input type="hidden" name="deliveryDate" id="deliveryDate" />
<input type="hidden" name="investId" id="investId"  />
<input type="hidden" name="pageNo" id="pageNo" value="${page.pageNo}"/>
   <div class="shenqing2">
		<table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="61">客户编号：</td>
            <td width="130px" style="color:#2E74D1;">
            <input type="text" id="customerCode" name="customerCode" value="${fortuneListForm.customerCode}" class="ggkj_inputtext_80"/>
            </td>
            <td width="85">客户姓名：</td>
            <td width="150px" style="color:#2E74D1;"><input type="text" id="cnName" name="cnName" value="${fortuneListForm.cnName}"  class="ggkj_inputtext_80"/>
            </td>
			<td width="85">投资编号：</td>
            <td width="150px" style="color:#2E74D1;"><input type="text" id="id" name="id" value="${fortuneListForm.id}"  class="ggkj_inputtext_80" />
            </td>
			<td width="85">投资日期：</td>
            <td width="250px" style="color:#2E74D1;">
            <input type="text" id="investStartDate" name="investStartDate" value="${fortuneListForm.investStartDate}" size="10" onClick="WdatePicker()" readonly="true"/>-
            <input type="text" id="investEndDate" name="investEndDate" value="${fortuneListForm.investEndDate}" size="10" onClick="WdatePicker()" readonly="true"/>
            <div id="investStartDate_check" style="display:none;"><font color="red">结束日期不能为空且不能小于开始日期</font></div>
            </td>
            <td width="85">投资状态：</td>
            <td width="150px" style="color:#2E74D1;">
            	<form:select path="flowId">
            	<option value="">请选择</option>
            	<flowdictionary:options type="0200" selectedValue="${fortuneListForm.flowId}"/>
            </form:select>
            </td>
			 <td width="93"><input name="Input" type="button" onclick="listsubmit_();" class="chaxun_btn" value="&nbsp;&nbsp;查询" />
             </td>
          </tr>
      </table>
    </div>
<div class="yiban">
	<table style="width:100%;" class="ggkj_table"  border="0" cellspacing="0" cellpadding="0">
  <tr>
    <th scope="col">投资编号</th>
    <th scope="col">合同编号</th>
    <th scope="col">出借编号</th>
    <th scope="col">客户姓名</th>
    <th scope="col">债权还款日</th>
    <th scope="col">实际投资金额</th>
    <th scope="col">实际投资日期</th>
    <th scope="col">理财产品</th>
    <th scope="col">状态</th>
    <th scope="col">操作</th>
  </tr>
  
	<c:forEach items="${page.result}" var="item" varStatus="stauts">
  			<c:if test="${stauts.count%2==0}">
  				<tr class="ggkj_tdColr">
  			</c:if>
  			<c:if test="${stauts.count%2!=0}">
  				<tr >
  			</c:if>
			<td>${item.id}</td>
			<td height="34">${item.protocolNo}</td>
			<td height="34">${item.customerInfo.customerCode}-${item.lendingNo}</td>
			<td><a href="${ctx}/fortune/invest_add_init/${item.customerInfo.id}?id=${item.id}&isShow=1">
			${fn:substring(item.customerInfo.cnName,0,4)}
			</a></td>
			<td><dictionary:display code="${item.loanReturnDate}"/>
			</td>
			<td>
			<c:if test="${item.regularType=='00130002'}">
				<fmt:formatNumber value="${item.regularAmt}" pattern="##,###.##"/>
			</c:if>
			<c:if test="${item.regularType=='00130001'}">
				<fmt:formatNumber value="${item.investAmt}" pattern="##,###.##"/>
			</c:if>
			</td>
			<td>
			<c:if test="${item.regularType=='00130002'}"><!-- 定投 -->
				<fmt:formatDate value="${item.regularStartDate}"   pattern="yyyy-MM-dd" type="date" dateStyle="long" />
			</c:if>
			<c:if test="${item.regularType=='00130001'}"><!-- 非定投 -->
				<fmt:formatDate value="${item.investStartDate}"   pattern="yyyy-MM-dd" type="date" dateStyle="long" />
			</c:if>
			</td>
			<td>
			<c:if test="${item.regularType=='00130001'}">
				<dictionary:display code="${item.productType}"/>
			</c:if>
			<c:if test="${item.regularType=='00130002'}">
				证大月定投
			</c:if>
			</td>
			
			<td>
				<c:if test="${item.id==1 || item.id==2 || item.id==3 || item.id==4}">
					投资生效
				</c:if>
				<c:if test="${item.id!=1 && item.id!=2 && item.id!=3 && item.id!=4 }">
					<flowdictionary:display code="${item.flowId}"/>
				</c:if>
			</td>
			<td> 
			<c:choose>
				<c:when test="${item.flowId=='02000002'}">
					<c:if test="${item.regularType=='00130002'}"><!-- 定投 -->
						<a href="#" id="transRecommend" name="transRecommend" onClick="recommend('<fmt:formatDate value="${item.regularStartDate}"  pattern="yyyy-MM-dd" type="date" dateStyle="long" />','${item.id}');">撮合交易</a>
					</c:if>
					<c:if test="${item.regularType=='00130001'}"><!-- 非定投 -->
						<a href="#" id="transRecommend" name="transRecommend" onClick="recommend('<fmt:formatDate value="${item.investStartDate}"  pattern="yyyy-MM-dd" type="date" dateStyle="long" />','${item.id}');">撮合交易</a>
					</c:if>
					| <a href="${ctx}/fortune/invest_add_init/${item.customerInfo.id}?id=${item.id}">变更</a>
					| <a href="#"  onClick="confirmInvalid(${item.id})">作废</a>
				</c:when>
				<c:otherwise>
					撮合交易
					| 变更
					| 作废
				</c:otherwise>
			</c:choose>
			</td>
		  </tr>
	</c:forEach>
</table>
	
</div>
<div class="ggkj_pagecontainer">
  <div class="ggkj_pageBGleft">
    	<span class="ggkj_pageBGright"></span>
    	<a href="javascript:jumpPage(1)" class="ggkj_pageUpa">
        
        </a>
        <a href="javascript:jumpPage(${page.prePage})" class="ggkj_pageUp">
        
        </a>
        <span class="ggkj_insertline"></span>
        <span class="ggkj_pageSpan">
        	页<input type="text" id="pageNo" name="pageNo" class="ggkj_inputtext_30" value="${page.pageNo}">OF ${page.totalPages}
        </span>
        <span class="ggkj_insertline"></span>
        <a href="javascript:jumpPage(${page.nextPage})" class="ggkj_pageDown">
        
        </a>
        <a href="javascript:jumpPage(${page.totalPages})" class="ggkj_pageDowna">
        
        </a>
        <span class="ggkj_insertline"></span>
    </div>
</div>
<div style="display:none">
	<div id="showbox" style="width:100px; height:100px;" class="yiban">
		<table width="100%" align="center"  cellspacing="0" cellpadding="0"  class="ggkj_table">
		<tr>
		  <TD colspan="2" class="er_banner"><span class="STYLE2">交易撮合</span> </TD>
		</tr>
		<tr><td colspan="3"></td></tr>
		<tr ><TD > 约定交割日期</TD>
		<td ><input type="text" id="return_Date" name="return_Date" tabindex="0" title="" value="" maxlength="10" size="12" readonly="true" /></td>
		</tr>
		<tr><td colspan="3"></td></tr>
		<tr>
		<td colspan="3" >
		<input type="button" value="&nbsp;&nbsp;&nbsp;&nbsp;查找债权"  class="tijiao_big" onClick="OpenMatchWindow();"/>&nbsp;&nbsp;&nbsp;<input type="button" value="&nbsp;&nbsp;&nbsp;&nbsp;返回" onClick="tb_remove();" class="quxiao_big"/>
		</td>
		</tr>
		</table>
		<hr   color="#FFFFFF"/>
	</div>
</div>

</form:form>
<script language="JavaScript">
document.body.onkeypress=function() 
{ 
    if   (event.keyCode   ==13){ 
		listsubmit_();
    }	
}
</script>
</body>
</html>
